cmake_minimum_required(VERSION 3.12)

project(CICD C)

set(INSTALL_DIR $ENV{HOME}/.cicd/)

execute_process(COMMAND rm -rf ${INSTALL_DIR})
execute_process(COMMAND mkdir ${INSTALL_DIR})

set(CMAKE_INSTALL_PREFIX
    ${INSTALL_DIR}
)

set(CMAKE_INSTALL_RPATH
    ${CMAKE_INSTALL_PREFIX}/
    ${CMAKE_INSTALL_PREFIX}/lib
)

add_compile_options(-Werror)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third/curl)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third/cJSON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/app)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.json DESTINATION ${INSTALL_DIR})